home *** CD-ROM | disk | FTP | other *** search
/ Revista CD Expert 37 / CD Expert nº 37.iso / LastCall / lastcall.exe / stuff / lastcall.dxr / 00096_Mixing Glass Behavior.ls < prev    next >
Encoding:
Text File  |  2000-03-27  |  4.8 KB  |  241 lines

  1. property pSpr, pLidUpMember, pOrigMember, pCapacity, pGlassMask, pGlassIce, pNoShadow, pPouring, pContents, pContentString, pTilt, pLastDest, pGlassType, pOverItem, pTimer, pLidUp, pLidTimer, pHotRect, pOrigInk, pLidUpInk
  2. global gFloatSprite
  3.  
  4. on beginSprite me
  5.   pGlassType = #mixingGlass
  6.   pSpr = sprite(me.spriteNum)
  7.   pGlassMask = sprite(me.spriteNum + 1)
  8.   pGlassIce = sprite(me.spriteNum - 1)
  9.   pOrigMember = pSpr.member
  10.   pOrigInk = 8
  11.   pSpr.ink = pOrigInk
  12.   pLidUpInk = 36
  13.   pLidUpMember = nextMember(pSpr.member, -1)
  14.   pNoShadow = nextMember(pSpr.member, -2)
  15.   pCapacity = getCapacity(pGlassType)
  16.   mEmptyGlass(me)
  17.   pLidUp = 0
  18.   pOverItem = 0
  19.   mReplaceIt(me)
  20.   pHotRect = rect(351, 312, 380, 377)
  21. end
  22.  
  23. on mEmptyGlass me
  24.   global gLastVessel
  25.   if gLastVessel = pGlassType then
  26.     setPourClockText(" The Mixing Glass is Empty")
  27.   end if
  28.   pContents = [:]
  29.   pContentString = EMPTY
  30.   sendSprite(pGlassMask, #mEmptyGlass)
  31.   sendSprite(pGlassIce, #mEmptyGlass)
  32.   pLastDest = VOID
  33. end
  34.  
  35. on mEmptyIfLastVessel me, barGlassSprite
  36.   if pLastDest = barGlassSprite then
  37.     mEmptyGlass(me)
  38.   end if
  39. end
  40.  
  41. on mSetOrigMember me
  42.   pSpr.member = pOrigMember
  43.   pSpr.ink = pOrigInk
  44. end
  45.  
  46. on mSetLidUpMember me
  47.   pSpr.member = pLidUpMember
  48.   pSpr.ink = pLidUpInk
  49. end
  50.  
  51. on mReplaceTop me
  52.   if pLidUp or (pSpr.member <> pOrigMember) then
  53.     pLidUp = 0
  54.     pLidTimer = VOID
  55.     soundFX2("strainer_on_mglass", 0, 0)
  56.     mSetOrigMember(me)
  57.   end if
  58. end
  59.  
  60. on mPopTop me, Force
  61.   if not pLidUp then
  62.     if not Force then
  63.       if voidp(pLidTimer) then
  64.         pLidTimer = nowTicks()
  65.         exit
  66.       else
  67.         if ticksSince(pLidTimer) < 15 then
  68.           exit
  69.         end if
  70.       end if
  71.     end if
  72.     soundFX2("strainer_off_mglass", 0, 0)
  73.     mSetLidUpMember(me)
  74.     pLidUp = 1
  75.     mupdateDisplay(me)
  76.   end if
  77. end
  78.  
  79. on mouseEnter me
  80.   if mInHotRect(me) then
  81.     pTimer = nowTicks()
  82.     pOverItem = 1
  83.     pLidTimer = VOID
  84.     if draggingBarTopGlass() then
  85.       exit
  86.     end if
  87.     showToolTip(pSpr, pGlassType)
  88.   end if
  89. end
  90.  
  91. on mupdateDisplay me
  92.   global gLastVessel
  93.   gLastVessel = pGlassType
  94.   pContentString = buildVesselContentList(pSpr, pGlassType, " The Mixing Glass is Empty")
  95.   showDrinkContents(pGlassType, pContentString, VOID)
  96. end
  97.  
  98. on mInHotRect me
  99.   return inside(the mouseLoc, pHotRect)
  100. end
  101.  
  102. on mouseWithin me
  103.   if mInHotRect(me) then
  104.     if draggingBottleOrSpoon() and not pPouring then
  105.       mPopTop(me)
  106.     else
  107.       if draggingIngredient() then
  108.         pTimer = nowTicks()
  109.       else
  110.         if tipTickRange(pTimer) then
  111.           forceToolTip(pSpr, pGlassType)
  112.           mupdateDisplay(me)
  113.         else
  114.           dismissToolTip()
  115.         end if
  116.       end if
  117.     end if
  118.   else
  119.     mouseLeave(me)
  120.   end if
  121. end
  122.  
  123. on mouseLeave me
  124.   if not pPouring and draggingBottleOrSpoon() then
  125.     mReplaceTop(me)
  126.   end if
  127.   pOverItem = 0
  128.   if not draggingSpoon() then
  129.     hideToolTip()
  130.     hideDrinkContents()
  131.   end if
  132. end
  133.  
  134. on mouseDown me
  135.   if the doubleClick then
  136.     exit
  137.   end if
  138.   if draggingBottleOrSpoon() and not pPouring then
  139.     mPopTop(me, 1)
  140.     if draggingBottleThang() then
  141.       pourIt(mGetReceiveSound(me))
  142.     end if
  143.   else
  144.     if pPouring then
  145.       mReplaceIt(me)
  146.       replaceDraggingAnything()
  147.     else
  148.       replaceDraggingAnything()
  149.       mSetOrigMember(me)
  150.       sendSprite(gFloatSprite, #mPickUpBottle, pSpr, 1, VOID, pGlassType, mGetPourSound(me))
  151.       pPouring = 1
  152.       pSpr.member = pNoShadow
  153.       sendSprite(pGlassMask, #mHideDrink)
  154.       sendSprite(pGlassIce, #mHideDrink)
  155.       updateStage()
  156.     end if
  157.   end if
  158. end
  159.  
  160. on mGetReceiveSound me
  161.   if mHasIce(me) then
  162.     soundName = "water_into_mglass_wice"
  163.   else
  164.     soundName = "water_into_mglass"
  165.   end if
  166.   return soundName
  167. end
  168.  
  169. on mGetPourSound me
  170.   if mIsEmpty(me) then
  171.     soundName = VOID
  172.   else
  173.     soundName = "strain_mglass"
  174.   end if
  175.   return soundName
  176. end
  177.  
  178. on mStirred me
  179.   if countStirrableIngredients(pContents) > 1 then
  180.     pContents[#stir] = 1
  181.   end if
  182. end
  183.  
  184. on mIsHoldingVolume me
  185.   return calcContents(pContents)
  186. end
  187.  
  188. on mIsHoldingLiquor me
  189.   return calcLiquorContents(pContents)
  190. end
  191.  
  192. on mIsHoldingLiquid me
  193.   return calcLiquidContents(pContents)
  194. end
  195.  
  196. on mIsHoldingPourable me
  197.   return calcPourableContents(pContents)
  198. end
  199.  
  200. on mIsEmpty me
  201.   return calcEmpty(pContents)
  202. end
  203.  
  204. on mHasIce me
  205.   if voidp(pContents[#ice]) then
  206.     return 0
  207.   else
  208.     return integer(pContents[#ice])
  209.   end if
  210. end
  211.  
  212. on mOverItem me, bottleSprite, spoutLoc
  213.   if pPouring then
  214.     return 0
  215.   else
  216.     withinHotRect = inside(spoutLoc, pHotRect)
  217.     if withinHotRect then
  218.       if pOverItem then
  219.         mouseWithin(me)
  220.       else
  221.         mouseEnter(me)
  222.       end if
  223.     else
  224.     end if
  225.     return withinHotRect
  226.   end if
  227. end
  228.  
  229. on mReplaceIt me
  230.   mSetOrigMember(me)
  231.   pSpr.visible = 1
  232.   sendSprite(pGlassMask, #mShowDrink)
  233.   sendSprite(pGlassIce, #mShowDrink)
  234.   pTilt = #left
  235.   pPouring = 0
  236. end
  237.  
  238. on mFill me, ingredient, liquidColor
  239.   return fillVessel(me, ingredient, liquidColor)
  240. end
  241.